package com.example.aop.aspect;


import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;

@Slf4j
@Order(1)
//@Aspect
@Configuration
public class AspectDemo1 {

//    @Around("execution(* com.example.aop.controller.*.*(..))")
//    public Object timeRecord(ProceedingJoinPoint joinPoint) throws Throwable {
//        long start = System.currentTimeMillis();
//        Object result = joinPoint.proceed();
//        long end = System.currentTimeMillis();
//        log.info("耗时：" + (end - start) + "ms");
//        return result;
//    }
    @Pointcut("execution(* com.example.aop.controller.*.*(..))")
    public void pc(){};



    @Before("pc()")
    public void before() {
        log.info("demo1 before==========");
    }

    @After("pc()")
    public void after() {
        log.info("demo1 after==========");
    }

//    @Around("pc()")
//    public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
//        log.info("demo1 around before==========");
//        Object result = joinPoint.proceed();
//        log.info("demo1 around after==========");
//        return result;
//    }
//
//    @AfterReturning("pc()")
//    public void afterReturning() {
//        log.info("demo1 afterReturning==========");
//    }
//
//    @AfterThrowing("pc()")
//    public void afterThrowing() {
//        log.info("demo1 afterThrowing==========");
//    }
}
